package com.huangsm.cloud.consumer.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;

/**
 * 解决cors跨域问题
 * @author huangsm
 * @version V1.0
 */
@Configuration
public class WebMvcConfigurer {
    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurer() {
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/users/**")
                        .allowedOrigins("http://huangsm.zyx.com")
                        .allowedMethods("GET", "POST");
            }
        };
    }
}
